/***************************************************************************
*			Title: STYL Long run
*			Output:
*			Date:
****************************************************************************/
//set maxvar 20000

/*Create panel dataset with all rounds*/

   cd "${direc}/data/"


// Tempfile
	tempfile temp_adm tempp1_b tempp1_e3wks tempp1_e5m tempp2_b tempp2_e2w temp_b temp_e tempp2_e2w2w ///
	         tempp1_e7m tempp1_e12m tempp3_b tempp1_e13m tempp3_e2w tempp3_e5w tempp2_e12m tempp2_e13m ///
	         tempp3_e12m tempp3_e13m tempp1_e9y

// Round

	* r1 2w
	* r2 2w2w
	* r3 5m
	* r4 7m
	* r5 12m
	* r6 13m
    * r7 9yr

********************************************************************************
**************** 1. CLEAN DATASETS *****************************************
********************************************************************************

// ADM FILE

	use "prev/STYL_adm.dta", clear
	duplicates tag partid, gen (dup)
	assert dup ==0
	drop dup
	tostring *, replace force
	sort partid
	save "`temp_adm'", replace

// PHASE  1

	* P1_b
		use "prev/p1_baseline_clean.dta", clear

		* Check Duplicates
			duplicates tag partid, gen (dup)
			assert dup ==0
			drop dup

		* Suffixe _b
			unab allvar: _all
			foreach var of local allvar {
				ren `var' `var'_b
			}

		* ren id variables
			ren partid_b partid

		sort partid
		save "`tempp1_b'", replace

	* P1_e3wks
		use "prev/p1_end3wks_indiv_clean.dta", clear

		* Check Duplicates
			duplicates tag partid, gen (dup)
			assert dup ==0
			drop dup

		* Create survey id
			gen round = 1
			egen surveyid=concat(partid round), format( %12.0g)

		* Suffixe _e
			unab allvar: _all
			foreach var of local allvar {
				ren `var' `var'_e
			}

		* ren id variables
			ren partid_e partid
			ren surveyid_e surveyid
			ren round_e round

		* Dataset dummy
			gen p1_e3wks = 1
				la var p1_e3wks "Phase 1: Endline 3wks"

		drop round
		sort surveyid
		save "`tempp1_e3wks'", replace

	* P1_5mend

		use "prev/p1_end5m_clean.dta", clear

		* Check Duplicates
			duplicates tag partid, gen (dup)
			assert dup ==0
			drop dup

		* Create survey id
			gen round = 3
			egen surveyid=concat(partid round), format( %12.0g)

		* Suffixe _e
			unab allvar: _all
			foreach var of local allvar {
				ren `var' `var'_e
			}

		* ren id variables
			ren partid_e partid
			ren surveyid_e surveyid
			ren round_e round


		* Dataset dummy
			gen p1_e5m =1
				la var p1_e5m "Phase 1: Endline 5m"

		* Control duplicates
			duplicates tag surveyid, gen (dup)
			assert dup ==0
			drop dup

		drop round
		sort surveyid
		save "`tempp1_e5m'", replace

	* P1_7mend

		use "prev/p1_e7m_clean.dta", clear

		* Check Duplicates
			duplicates tag partid, gen (dup)
			assert dup ==0
			drop dup

		* Create survey id
			gen round = 4
			egen surveyid=concat(partid round), format( %12.0g)

		* Suffixe _e
			unab allvar: _all
			foreach var of local allvar {
				ren `var' `var'_e
			}

		* ren id variables
			ren partid_e partid
			ren surveyid_e surveyid
			ren round_e round


		* Dataset dummy
			gen p1_e7m =1
				la var p1_e7m "Phase 1: Endline 7m"

		* Control duplicates
			duplicates tag surveyid, gen (dup)
			assert dup ==0
			drop dup

		drop round
		sort surveyid
		save "`tempp1_e7m'", replace

	* p1_e12m

		use "prev/p1_e12m_clean.dta", clear

		* Check Duplicates
			duplicates tag partid, gen (dup)
			assert dup ==0
			drop dup

		* Create survey id
			gen round = 5
			egen surveyid=concat(partid round), format( %12.0g)

		* Suffixe _e
			unab allvar: _all
			foreach var of local allvar {
				ren `var' `var'_e
			}

		* ren id variables
			ren partid_e partid
			ren surveyid_e surveyid
			ren round_e round


		* Dataset dummy
			gen p1_e12m =1
				la var p1_e12m "Phase 1: Endline 12m"

		* Control duplicates
			duplicates tag surveyid, gen (dup)
			assert dup ==0
			drop dup

		drop round
		sort surveyid
		save "`tempp1_e12m'", replace

	* p1_e13m

		use "prev/p1_e13m_clean.dta", clear

		* Move back to cleaning code
			drop iwanttotalkaboutalcoholanddrugsb

		* Check Duplicates
			duplicates tag partid, gen (dup)
			assert dup ==0
			drop dup

		* Create survey id
			gen round = 6
			egen surveyid=concat(partid round), format( %12.0g)

		* Suffixe _e
			unab allvar: _all
			foreach var of local allvar {
				ren `var' `var'_e
			}

		* ren id variables
			ren partid_e partid
			ren surveyid_e surveyid
			ren round_e round


		* Dataset dummy
			gen p1_e13m =1
				la var p1_e13m "Phase 1: Endline 13m"

		* Control duplicates
			duplicates tag surveyid, gen (dup)
			assert dup ==0
			drop dup

		drop round
		sort surveyid
		save "`tempp1_e13m'", replace





// PHASE 2

	* P2_b
		use "prev/p2_baseline_clean.dta", clear

		* Check Duplicates
			duplicates tag partid, gen (dup)
			assert dup ==0
			drop dup

		* Suffixe _b
			unab allvar: _all
			foreach var of local allvar {
				ren `var' `var'_b
			}

		* ren id variables
			ren  partid_b partid

		sort partid
		save "`tempp2_b'", replace

	* P2_e2w

		use "prev/p2_end2wks_clean.dta" , clear

		* temp to check
			capture drop ADM- adm_merge

		* Check Duplicates
			duplicates tag partid, gen (dup)
			assert dup ==0
			drop dup

		 * Create survey id
			gen round = 1
			egen surveyid=concat(partid round)

		* Suffixe _e
			unab allvar: _all
			foreach var of local allvar {
				ren `var' `var'_e
			}

		* Dataset dummy
			gen p2_e2wks =1
				la var p2_e2wks "Phase 2: Endline 2wks"

		* ren id variables
			ren partid_e partid
			ren surveyid_e surveyid
			ren round_e round


		* Control duplicates
			duplicates tag surveyid, gen (dup)
			assert dup ==0
			drop dup

		drop round
		sort surveyid
		save "`tempp2_e2w'", replace

	* P2_e2w2w
		use "prev/p2_e2w2w_clean.dta", clear

		* Check Duplicates
			duplicates tag partid, gen (dup)
			assert dup ==0
			drop dup

		* Create survey id
			gen round = 2
			egen surveyid=concat(partid round), format( %12.0g)

		* Suffixe _e
			unab allvar: _all
			foreach var of local allvar {
				ren `var' `var'_e
			}

		* Dataset dummy
			gen p2_e2w2w =1
				la var p2_e2w2w "Phase 2: Endline 2w2w"

		* ren id variables
			ren partid_e partid
			ren surveyid_e surveyid
			ren round_e round


		* Control duplicates
			duplicates tag surveyid, gen (dup)
			assert dup ==0
			drop dup

		drop round
		sort surveyid
		save "`tempp2_e2w2w'", replace

	* P2_e12m
		use "prev/p2_end12m_clean.dta", clear

		* Check Duplicates
			duplicates tag partid, gen (dup)
			assert dup ==0
			drop dup

		* Create survey id
			gen round = 5
			egen surveyid=concat(partid round), format( %12.0g)

		* Suffixe _e
			unab allvar: _all
			foreach var of local allvar {
				ren `var' `var'_e
			}

		* Dataset dummy
			gen p2_e12m=1
				la var p2_e12m "Phase 2: Endline 12m"

		* ren id variables
			ren partid_e partid
			ren surveyid_e surveyid
			ren round_e round


		* Control duplicates
			duplicates tag surveyid, gen (dup)
			assert dup ==0
			drop dup

		drop round
		sort surveyid
		save "`tempp2_e12m'", replace

	* P2_e13m
		use "prev/p2_end13m_clean.dta", clear

		* Check Duplicates
			duplicates tag partid, gen (dup)
			assert dup ==0
			drop dup

		* Create survey id
			gen round = 6
			egen surveyid=concat(partid round), format( %12.0g)

		* Suffixe _e
			unab allvar: _all
			foreach var of local allvar {
				ren `var' `var'_e
			}

		* Dataset dummy
			gen p2_e13m=1
				la var p2_e13m "Phase 2: Endline 13m"

		* ren id variables
			ren partid_e partid
			ren surveyid_e surveyid
			ren round_e round


		* Control duplicates
			duplicates tag surveyid, gen (dup)
			assert dup ==0
			drop dup

		drop round
		sort surveyid
		save "`tempp2_e13m'", replace

// PHASE 3

	* p3_b
		use "prev/p3_baseline_clean.dta", clear

		* Check Duplicates
			duplicates tag partid, gen (dup)
			assert dup ==0
			drop dup

		* Suffixe _b
			unab allvar: _all
			foreach var of local allvar {
				ren `var' `var'_b
			}

		* ren id variables
			ren  partid_b partid

		sort partid
		save "`tempp3_b'", replace

	* P3_e2w
		use "prev/p3_end2w_clean.dta", clear

		* Check Duplicates
			duplicates tag partid, gen (dup)
			assert dup ==0
			drop dup

		* Create survey id
			gen round = 1
			egen surveyid=concat(partid round), format( %12.0g)

		* Suffixe _e
			unab allvar: _all
			foreach var of local allvar {
				ren `var' `var'_e
			}

		* Dataset dummy
			gen p3_e2w =1
				la var p3_e2w "Phase 3: Endline 2w"

		* ren id variables
			ren partid_e partid
			ren surveyid_e surveyid
			ren round_e round


		* Control duplicates
			duplicates tag surveyid, gen (dup)
			assert dup ==0
			drop dup

		drop round
		sort surveyid
		save "`tempp3_e2w'", replace

 * P3_e5w
		use "prev/p3_end5w_clean.dta", clear

		* Check Duplicates
			duplicates tag partid, gen (dup)
			assert dup ==0
			drop dup

		* Create survey id
			gen round = 2
			egen surveyid=concat(partid round), format( %12.0g)

		* Suffixe _e
			unab allvar: _all
			foreach var of local allvar {
				ren `var' `var'_e
			}

		* Dataset dummy
			gen p3_e5w =1
				la var p3_e5w "Phase 3: Endline 5w"

		* ren id variables
			ren partid_e partid
			ren surveyid_e surveyid
			ren round_e round



		* Control duplicates
			duplicates tag surveyid, gen (dup)
			assert dup ==0
			drop dup

		drop round
		sort surveyid
		save "`tempp3_e5w'", replace

* P3_e12m
		use "prev/p3_end12m_clean.dta", clear

		* Check Duplicates
			duplicates tag partid, gen (dup)
			assert dup ==0
			drop dup

		* Create survey id
			gen round = 5
			egen surveyid=concat(partid round), format( %12.0g)

		* Suffixe _e
			unab allvar: _all
			foreach var of local allvar {
				ren `var' `var'_e
			}

		* Dataset dummy
			gen p3_e12m =1
				la var p3_e12m "Phase 3: Endline 12m"

		* ren id variables
			ren partid_e partid
			ren surveyid_e surveyid
			ren round_e round



		* Control duplicates
			duplicates tag surveyid, gen (dup)
			assert dup ==0
			drop dup

		drop round
		sort surveyid
		save "`tempp3_e12m'", replace

* P3_e13m
		use "prev/p3_end13m_clean.dta", clear

		* Check Duplicates
			duplicates tag partid, gen (dup)
			assert dup ==0
			drop dup

		* Create survey id
			gen round = 6
			egen surveyid=concat(partid round), format( %12.0g)

		rename pettytradematerialsflowamtspecif pettytradespecif
		rename pettytradebizstructflowamtspecif pettytradebizspecif
		rename carryloadmaterialsflowamtspecify carryloadspecif
		rename guardbizstructflowamtunitspecify guardbizspecif
		rename houseclswpmaterialsamtflowspecif housespecif
		rename houseclswpbizstructflowamtspecif housebizspecif
		rename scavengematerialsflowamtspecify scavengespecif
		rename scavengebizstructflowamtspecify scavengebizspecif
		rename drugsellmaterialsflowamtspecify drugsellspecif
		rename drugsellbizstructflowamtspecify drugsellbizspecif
		rename workoth1materialsflowamtspecify workoth1specif
		rename workoth1bizstructflowamtspecify workoth1bizspecif
		rename workoth2materialsflowamtspecify workoth2specif
		rename workoth2bizstructflowamtspecify workoth2bizspecif

		* Suffixe _e
			unab allvar: _all
			foreach var of local allvar {
				ren `var' `var'_e
			}

		* Dataset dummy
			gen p3_e13m =1
				la var p3_e13m "Phase 3: Endline 13m"

		* ren id variables
			ren partid_e partid
			ren surveyid_e surveyid
			ren round_e round



		* Control duplicates
			duplicates tag surveyid, gen (dup)
			assert dup ==0
			drop dup

		drop round
		sort surveyid
		save "`tempp3_e13m'", replace


* P1_e9y
		use "clean/STYL_10yrs_clean.dta", clear
        cap drop dup

		* Check Duplicates
			duplicates tag partid longrun_r2, gen (dup)
			assert dup ==0
			drop dup

		* Create survey id
		* Sahil's tag: The comparison to 0 was causing an issue. Changed it to 0-Master.
			gen round = cond(longrun_r2=="0-Master",7,8)
			egen surveyid=concat(partid round), format( %12.0g)

		* Suffixe _e
			unab allvar: _all
			foreach var of local allvar {
				ren `var' `var'_e
			}

		* ren id variables
			ren partid_e partid
			ren surveyid_e surveyid
			ren round_e round


		* Control duplicates
			duplicates tag surveyid, gen (dup)
			assert dup ==0
			drop dup

        *
          gen e9y=1

     	drop round
		sort surveyid

    	save "`tempp1_e9y'", replace


********************************************************************************
**************** 2. COMBINE DATASETS ***************************************
********************************************************************************

// APPEND BASELINE DATA

	use "`tempp2_b'"
	append using "`tempp1_b'"
	append using "`tempp3_b'"

	duplicates tag partid, gen (dup)
	assert dup ==0
	drop dup

	sort partid
	save "`temp_b'", replace

// APPEND ENDLINE DATA

	use "`tempp1_e5m'", clear
	append using "`tempp1_e3wks'"
	append using "`tempp1_e7m'"
	append using "`tempp1_e12m'"
	append using "`tempp1_e13m'"
	append using "`tempp2_e2w'"
	append using "`tempp2_e2w2w'"
	append using "`tempp2_e12m'"
	append using "`tempp2_e13m'"
	append using "`tempp3_e2w'"
	append using "`tempp3_e5w'"
	append using "`tempp3_e12m'"
	append using "`tempp3_e13m'"
    append using "`tempp1_e9y'"

	duplicates tag surveyid, gen (dup)
	assert dup ==0
	drop dup

	sort surveyid
	save "`temp_e'", replace

// MERGE IN BASELINE DATA

	use "`temp_adm'", clear
	merge partid using "`temp_b'", _merge (_merge_b)

	* Control the merge
		assert _merge_b ==3

	* Control duplicates
		duplicates tag partid, gen (dup)
		assert dup ==0
		drop dup

// EXPAND DATASET
	* r1 2w
	* r2 2w2w
	* r3 5m
	* r4 7m
	* r5 12m
	* r6 13m

	* p1 we have round 1, round 3 and round 4, round 5 and round 6   (3w, 5m, 7m, 12m, 13m, 9y)
		expand 7 if p1 =="1"

	* p2 we have round 1 and round 2 and round 5(2w,2w2w, 12m, 13m, 9y)
		expand 6 if p2 =="1"

	* p3 we have round 1 and round 2(2w,5w, 9y)
		expand 6 if p3 =="1"

	* create round dummy
		bys partid: gen round =_n
		    replace round = 8 if round ==7 & p1 == "1"
		    replace round = 7 if round ==6 & p1 == "1"
			replace round = 6 if round ==5 & p1 == "1"
			replace round = 5 if round ==4 & p1 == "1"
			replace round = 4 if round ==3 & p1 == "1"
			replace round = 3 if round ==2 & p1 == "1"

            replace round = 8 if round ==6 & p2 == "1"
	        replace round = 7 if round ==5 & p2 == "1"
		    replace round = 6 if round ==4 & p2 == "1"
			replace round = 5 if round ==3 & p2 == "1"

			replace round = 8 if round ==6 & p3 == "1"
			replace round = 7 if round ==5 & p3 == "1"
			replace round = 6 if round ==4 & p3 == "1"
		    replace round = 5 if round ==3 & p3 == "1"

			la var round "Round"

// CREATE A NEW UNIQUE ID FOR EACH SURVEY ROUND

	egen surveyid=concat(partid round)
		la var surveyid "Survey ID"

	* Control duplicates
		duplicates tag surveyid, gen (dup)
		assert dup ==0
		drop dup

// CREATE ROUND DUMMIES
	gen r1 = (round ==1)
		la var r1 "Round 1: 2w"

	gen r2 = (round ==2)
		la var r2 "Round 2: 2w+2ws"

	gen r3 = (round ==3)
		la var r3 "Round 3: 5m"

	gen r4 = (round ==4)
		la var r4 "Round 4: 7m"

	gen r5 = (round ==5)
		la var r5 "Round 5: 12m"

	gen r6 = (round ==6)
		la var r6 "Round 5: 13m"

	gen r7 = (round ==7)
		la var r7 "Round 6: 9yr"

	gen r8 = (round ==8)
		la var r8 "Round 7: 10yr"

// MERGE IN ENDLINE DATA

	sort surveyid
	merge surveyid using "`temp_e'", _merge (_merge_e)

	* Control the merge
		drop  if _merge_e ==2

	* Check duplicates
		duplicates tag surveyid, gen (dup)
		assert dup ==0
		drop dup

// Create long term wave dummies

  gen p1_e9y = 1 if p1=="1" & r7==1 & e9y==1
  gen p2_e9y = 1 if p2=="1" & r7==1 & e9y==1
  gen p3_e9y = 1 if p3=="1" & r7==1 & e9y==1

  gen p1_e10y = 1 if p1=="1" & r8==1 & e9y==1
  gen p2_e10y = 1 if p2=="1" & r8==1 & e9y==1
  gen p3_e10y = 1 if p3=="1" & r8==1 & e9y==1

// MERGE IN ATTRITION DATA
	merge 1:1 partid round using "clean/STYL_all_attrition.dta"

// ANONYMISE DATASET
	* done in individual clean files now
	*drop name firstname lastname  nickname lastname_b firstname_b nickname_b glastname_b gfirstname_b  lastname_e glastname_e gfirstname_e stylidname_e firstname_e nickname_e fakename_e fakenamespecify_e

// ORGANISZE DATASET

	* Dataset Dummies
		destring p1 p2 p3 r1 r2 r3 r4 r5 r6 r7 p1_e3wks p1_e5m p2_e2wks p2_e2w2w p1_e12m p1_e13m p3_e2w p3_e5w p2_e12m p2_e13m p3_e12m p3_e13m p1_e9y p2_e9y p3_e9y p1_e10y p2_e10y p3_e10y , replace

		foreach x in p1 p2  p3 r1 r2 r3 r4 p1_e3wks p1_e5m p2_e2wks p2_e2w2w p1_e7m p1_e12m p1_e13m p3_e2w p3_e5w p2_e12m p2_e13m p3_e12m p3_e13m  p1_e9y p2_e9y p3_e9y p1_e10y p2_e10y p3_e10y {
			replace `x' = 0 if `x'==.
		}

	* Create dummy for having been surveyed

		foreach p in 1 2 3 {
			foreach r in 1 2 3 4 5 6 7 8{
				gen surveyed_p`p'_r`r'_b=1 if p`p'==1 & r`r'==1
			}
		}



		la var surveyed_p1_r1_b "Surveyed: Phase1 Baseline"
		la var surveyed_p1_r2_b "Surveyed: Phase1 Baseline"
		la var surveyed_p1_r3_b "Surveyed: Phase1 Baseline"
		la var surveyed_p1_r4_b "Surveyed: Phase1 Baseline"
		la var surveyed_p1_r5_b "Surveyed: Phase1 Baseline"
		la var surveyed_p1_r6_b "Surveyed: Phase1 Baseline"
		la var surveyed_p1_r7_b "Surveyed: Phase1 Baseline"
	    la var surveyed_p1_r8_b "Surveyed: Phase1 Baseline"

		la var surveyed_p2_r1_b "Surveyed: Phase2 Baseline"
		la var surveyed_p2_r2_b "Surveyed: Phase2 Baseline"
		la var surveyed_p2_r3_b "Surveyed: Phase2 Baseline"
		la var surveyed_p2_r4_b "Surveyed: Phase2 Baseline"
		la var surveyed_p2_r5_b "Surveyed: Phase2 Baseline"
		la var surveyed_p2_r6_b "Surveyed: Phase2 Baseline"
		la var surveyed_p2_r7_b "Surveyed: Phase2 Baseline"
		la var surveyed_p2_r8_b "Surveyed: Phase2 Baseline"

		la var surveyed_p3_r1_b "Surveyed: Phase3 Baseline"
		la var surveyed_p3_r2_b "Surveyed: Phase3 Baseline"
		la var surveyed_p3_r3_b "Surveyed: Phase3 Baseline"
		la var surveyed_p3_r4_b "Surveyed: Phase3 Baseline"
		la var surveyed_p3_r5_b "Surveyed: Phase3 Baseline"
		la var surveyed_p3_r6_b "Surveyed: Phase3 Baseline"
		la var surveyed_p3_r7_b "Surveyed: Phase3 Baseline"
		la var surveyed_p3_r8_b "Surveyed: Phase3 Baseline"

		gen surveyed_p1_r1_e=(p1_e3wks==1)
			la var surveyed_p1_r1_e "Surveyed: Phase1 3w"
		gen surveyed_p1_r2_e=0
			la var surveyed_p1_r2_e "Surveyed: Phase1 2w2w"
		gen surveyed_p1_r3_e=(p1_e5m==1)
			la var surveyed_p1_r3_e "Surveyed: Phase1 5m"
		gen surveyed_p1_r4_e=(p1_e7m==1)
			la var surveyed_p1_r4_e "Surveyed: Phase1 7m"
		gen surveyed_p1_r5_e=(p1_e12m==1)
			la var surveyed_p1_r5_e "Surveyed: Phase1 12m"
		gen surveyed_p1_r6_e=(p1_e13m==1)
			la var surveyed_p1_r6_e "Surveyed: Phase1 13m"
		gen surveyed_p1_r7_e=(p1_e9y==1)
			la var surveyed_p1_r7_e "Surveyed: Phase1 9yr"
		gen surveyed_p1_r8_e=(p1_e10y==1)
			la var surveyed_p1_r8_e "Surveyed: Phase1 10yr"

		gen surveyed_p2_r1_e=(p2_e2wks==1)
			la var  surveyed_p2_r1_e "Surveyed: Phase2 2w"
		gen surveyed_p2_r2_e=(p2_e2w2w==1)
			la var surveyed_p2_r2_e "Surveyed: Phase2 2w2w"
		gen surveyed_p2_r5_e=(p2_e12m==1)
			la var  surveyed_p2_r5_e "Surveyed: Phase2 12m"
		gen surveyed_p2_r6_e=(p2_e13m==1)
			la var  surveyed_p2_r6_e "Surveyed: Phase2 13m"
		gen surveyed_p2_r7_e=(p2_e9y==1)
			la var  surveyed_p2_r7_e "Surveyed: Phase2 9yr"
		gen surveyed_p2_r8_e=(p2_e10y==1)
			la var  surveyed_p2_r8_e "Surveyed: Phase2 10yr"


		gen surveyed_p3_r1_e=(p3_e2w==1)
			la var surveyed_p3_r1_e "Surveyed: Phase3 2w"
		gen surveyed_p3_r2_e=(p3_e5w==1)
			la var surveyed_p3_r2_e "Surveyed: Phase3 5w"
		gen surveyed_p3_r5_e=(p3_e12m==1)
			la var  surveyed_p2_r5_e "Surveyed: Phase3 12m"
     	gen surveyed_p3_r6_e=(p3_e13m==1)
			la var  surveyed_p3_r6_e "Surveyed: Phase3 13m"
		gen surveyed_p3_r7_e=(p3_e9y==1)
			la var  surveyed_p3_r7_e "Surveyed: Phase3 9yr"
		gen surveyed_p3_r8_e=(p3_e10y==1)
			la var  surveyed_p3_r8_e "Surveyed: Phase3 10yr"


// MOVE BACK INTO INDIVIDUAL DOFILES
	*ren endtime_e cclendtime_e
	*ren enddate_e  cclenddate_e

// SECTION BREAKS FOR BASELINE

	gen BASELINE  = .
	la var BASELINE  "________________________"
	move BASELINE    warname_b

	gen INTRO_b  = .
	la var INTRO_b  "________________________"
	move INTRO_b   timestamp_00_b

	gen CONSENT_b = .
	la var CONSENT_b "________________________"
	move CONSENT_b    timestamp_001_b

	gen DELAY_GRATIFICATION_b = .
	la var DELAY_GRATIFICATION_b "________________________"
	move DELAY_GRATIFICATION_b    timestamp_02_b

	gen DEMO_b = .
	la var DEMO_b "________________________"
	move DEMO_b   timestamp_03_b

	gen HEALTH_b = .
	la var HEALTH_b "________________________"
	move HEALTH_b  timestamp_04_b

	gen PATRON_CLIENT_b = .
	la var PATRON_CLIENT_b "________________________"
	move PATRON_CLIENT_b  timestamp_05_b

	gen TIME_RISK_b = .
	la var TIME_RISK_b "________________________"
	move TIME_RISK_b   timestamp_06_b

	gen ECO_ACT_b = .
	la var ECO_ACT_b "________________________"
	move ECO_ACT_b   timestamp_07_b

	gen FINANCIAL_b = .
	la var FINANCIAL_b "________________________"
	move FINANCIAL_b timestamp_08_b

	gen WAR_b = .
	la var WAR_b "________________________"
	move WAR_b  timestamp_09_b

	gen NEO_PERSO_b = .
	la var NEO_PERSO_b "________________________"
	move NEO_PERSO_b   timestamp_10_b

	gen DRUGS_b = .
	la var DRUGS_b "________________________"
	move DRUGS_b   timestamp_11_b

	gen HOUSING_b = .
	la var HOUSING_b "________________________"
	move HOUSING_b  timestamp_12_b

	gen BARETTASB_b	= .
	la var BARETTASB_b "________________________"
	move BARETTASB_b  timestamp_13_b

	gen PSYCHOSOCIAL_b = .
	la var PSYCHOSOCIAL_b "________________________"
	move PSYCHOSOCIAL_b  timestamp_14_b

	gen FAMILY_PEER_b = .
	la var FAMILY_PEER_b "________________________"
	move FAMILY_PEER_b   timestamp_15_b

	gen CONSUMPTION_b = .
	la var CONSUMPTION_b "________________________"
	move CONSUMPTION_b  timestamp_16_b

	gen HUSTLE_b = .
	la var HUSTLE_b "________________________"
	move HUSTLE_b timestamp_17_b

	gen VOTING_b	= .
	la var VOTING_b "________________________"
	move VOTING_b timestamp_18_b

	gen GRITBAS_b	= .
	la var GRITBAS_b "________________________"
	move GRITBAS_b timestamp_19_b

	gen COMMUNITY_b	= .
	la var COMMUNITY_b "________________________"
	move COMMUNITY_b  timestamp_20_b

	gen GENDER_b	= .
	la var GENDER_b "________________________"
	move GENDER_b  timestamp_21_b

	gen HOUSEHOLD_b	= .
	la var HOUSEHOLD_b "________________________"
	move HOUSEHOLD_b timestamp_22_b

	gen ASSETS_b	= .
	la var ASSETS_b "________________________"
	move ASSETS_b timestamp_23_b

	gen LOCUSESTEEM_b	= .
	la var LOCUSESTEEM_b "________________________"
	move LOCUSESTEEM_b timestamp_24_b

	gen POLVIOL_b = .
	la var POLVIOL_b "________________________"
	move POLVIOL_b  pvpeerjoinloot_b


	gen CCL_b	= .
	la var CCL_b "________________________"
	move CCL_b timestamp_25_b

	gen GAMES_INTRO_b = .
	la var GAMES_INTRO_b "________________________"
	move GAMES_INTRO_b stime_IBM00_b

	gen GAMES_PUZZLE_b = .
	la var GAMES_PUZZLE_b "________________________"
	move GAMES_PUZZLE_b stime_IBM01_b

	gen GAMES_MAZE_b = .
	la var GAMES_MAZE_b "________________________"
	move GAMES_MAZE_b stime_IBM02_b

	gen GAMES_ARROW_b = .
	la var GAMES_ARROW_b "________________________"
	move GAMES_ARROW_b stime_IBM03_b

	gen GAMES_FROG_b = .
	la var GAMES_FROG_b "________________________"
	move GAMES_FROG_b  stime_IBM04_b

	gen GAMES_LITERACY_b = .
	la var GAMES_LITERACY_b  "________________________"
	move GAMES_LITERACY_b stime_IBM05_b

	gen GAMES_MEMORY_b = .
	la var GAMES_MEMORY_b "________________________"
	move GAMES_MEMORY_b  stime_IBM06_b

	gen GAMES_MONEY_b = .
	la var GAMES_MONEY_b "________________________"
	move GAMES_MONEY_b  stime_IBM07_b


// SECTION BREAKS FOR ENDLINE

	gen INTRO_e = .
	la var INTRO_e "________________________"
	move INTRO_e    timestamp_00_e

	gen ENDLINE_e = .
	la var ENDLINE_e  "________________________"
	move ENDLINE_e INTRO_e

	gen CONSENT_e = .
	la var CONSENT_e  "________________________"
	move CONSENT_e  timestamp_01_e

	gen DELAY_GRATIFICATION_e = .
	la var DELAY_GRATIFICATION_e  "________________________"
	move DELAY_GRATIFICATION_e  timestamp_02_e

	gen DEMO_e = .
	la var DEMO_e  "________________________"
	move DEMO_e      timestamp_03_e

	gen CLIENT_PATRON_e = .
	la var CLIENT_PATRON_e "________________________"
	move CLIENT_PATRON_e       timestamp_04_e

	gen TIME_RISK_e = .
	la var TIME_RISK_e "________________________"
	move TIME_RISK_e        timestamp_05_e

	gen PROG_EXP_e = .
	la var PROG_EXP_e  "________________________"
	move PROG_EXP_e   timestamp_06_e

	gen ECO_ACT_e = .
	la var ECO_ACT_e  "________________________"
	move ECO_ACT_e    timestamp_07_1_e

	gen FINANCIAL_e = .
	la var FINANCIAL_e  "________________________"
	move FINANCIAL_e    timestamp_08_e

	gen NEO_PERSO_e = .
	la var NEO_PERSO_e "________________________"
	move NEO_PERSO_e     timestamp_09_e

	gen DRUG_e = .
	la var DRUG_e  "________________________"
	move DRUG_e   timestamp_10_e

	gen HOUSING_e = .
	la var HOUSING_e "________________________"
	move HOUSING_e   timestamp_11_e

	gen BARRETT_ASB_e = .
	la var BARRETT_ASB_e  "________________________"
	move BARRETT_ASB_e   timestamp_12_e

	gen CONSUMPTION_e = .
	la var CONSUMPTION_e  "________________________"
	move CONSUMPTION_e   timestamp_13_e

	gen HUSTLE_e = .
	la var HUSTLE_e  "________________________"
	move HUSTLE_e    timestamp_14_e

	gen VOTING_e = .
	la var VOTING_e  "________________________"
	move VOTING_e  timestamp_15_e

	gen GRIT_BAS_e = .
	la var GRIT_BAS_e  "________________________"
	move GRIT_BAS_e   timestamp_16_e

	gen COMMUNITY_e = .
	la var COMMUNITY_e  "________________________"
	move COMMUNITY_e    timestamp_17_e

	gen HEALTH_e = .
	la var HEALTH_e "________________________"
	move HEALTH_e     timestamp_18_e

	gen HOUSEHOLD_e = .
	la var HOUSEHOLD_e "________________________"
	move HOUSEHOLD_e     hhunder15_e

	gen ASSETS_e = .
	la var ASSETS_e  "________________________"
	move ASSETS_e  timestamp_19_e

	gen LC_SE_e = .
	la var LC_SE_e  "________________________"
	move LC_SE_e   timestamp_20_e

	gen CCL_e = .
	la var CCL_e  "________________________"
	move CCL_e  timestamp_21_e

	gen BUSINESS_EXP_e = .
	label var BUSINESS_EXP_e  "________________________"
	move BUSINESS_EXP_e    inventoryamt_e

	gen PEER_e = .
	la var  PEER_e  "________________________"
	move PEER_e  peerschool_e

	gen WELLBEING_e = .
	la var WELLBEING_e "________________________"
	move WELLBEING_e  ladderrich_e

	gen IDV_e = .
	la var IDV_e "________________________"
	move IDV_e  idv_bornlib_e

	gen NORMSVIOL_e = .
	la var NORMSVIOL_e "________________________"
	move NORMSVIOL_e   nvstrangerrob_e

	gen NORMCRIM_e = .
	la var NORMCRIM_e "________________________"
	move NORMCRIM_e   attstchinamanbeat_e

	gen POLVIOL_e = .
	la var POLVIOL_e "________________________"
	move POLVIOL_e pvtalkdemst_e

	gen COLLVIOL_e = .
	la var COLLVIOL_e "________________________"
	move COLLVIOL_e cvtalkdemstpc_e

	gen ELECTIONS_e = .
	la var ELECTIONS_e  "________________________"
	move ELECTIONS_e    vo2011octvote_e

	gen CHRISTRIOTS_e = .
	la var CHRISTRIOTS_e  "________________________"
	move CHRISTRIOTS_e     crsee2011xriot_e


	gen GENDER_e = .
	label var GENDER_e  "________________________"
	move GENDER_e    mmarried_e

	gen PSYCHO_e = .
	label var PSYCHO_e  "________________________"
	move PSYCHO_e     laddernow_e

	gen IVORY_COAST_e = .
	label var IVORY_COAST_e  "________________________"
	move IVORY_COAST_e    icconfcause_e

	gen HABITS_e = .
	label var HABITS_e  "________________________"
	move HABITS_e  hab1try_e

	gen GAMES_INTRO_e = .
	la var GAMES_INTRO_e "________________________"
	move GAMES_INTRO_e stime_IBM00_e

	gen GAMES_PUZZLE_e = .
	la var GAMES_PUZZLE_e "________________________"
	move GAMES_PUZZLE_e stime_IBM01_e

	gen GAMES_MAZE_e = .
	la var GAMES_MAZE_e "________________________"
	move GAMES_MAZE_e stime_IBM02_e

	gen GAMES_ARROW_e = .
	la var GAMES_ARROW_e "________________________"
	move GAMES_ARROW_e stime_IBM03_e

	gen GAMES_LITERACY_e = .
	la var GAMES_LITERACY_e  "________________________"
	move GAMES_LITERACY_e stime_IBM04_e

	gen GAMES_MEMORY_e = .
	la var GAMES_MEMORY_e "________________________"
	move GAMES_MEMORY_e  stime_IBM05_e

	gen GAMES_MONEY_e = .
	la var GAMES_MONEY_e "________________________"
	*move GAMES_MONEY_e  stime_IBM06_e

	gen SUBJ_WB_e = .
	la var SUBJ_WB_e "________________________"

	gen SEX_ABUSE_e = .
	la var SEX_ABUSE_e "________________________"

	gen TIMING_WAREXP = .
	la var TIMING_WAREXP "________________________"

// PLACEVAR ADM
	placevar surveyid partid secretid mentunfit phase p1 p2 p3 round r1 r2 r3 r4 r5  r6 p1_e3wks p1_e5m p1_e7m p1_e12m p1_e13m p2_e2wks p2_e2w2w p3_e2w p3_e5w surveyed_p*, f

// PLACEVAR BASELINE

	* Delay Gratification
		placevar sdchoosecheck_b sdchoosechecktime_b wg_g1f_b wg_g1g_b wg_g1h_b wg_cclfinaltime_b wg_cclwater_b wg_cclwatertime_b, after (sdchooselater_b)

	* Demo
		placevar lvg1monrovia_b lvg1moncommty_b lvg1notmoncommty_b lvg1notmonsize_b lvg1notmoncty_b lvg1permres_b lvg2monrovia_b lvg2notmoncommty_b lvg2notmonsize_b lvg2notmoncty_b, after (borncntryoth_b)
		placevar relchristime_b relchristimeunit_b, after (relmeetunit_b)

	* Client Patron
		placevar ptrn4wamt_b  ptrn4wamtunit_b ptrneveramt_b ptrneveramtunit_b, after ( ptrndrugselleveramtunit_b)

	* Eco Activity
		placevar shop*_b table*_b buysell*_b pettytrade*_b trade*_b office*_b carload*_b carwash*_b moto*_b carryload*_b guard*_b houseclswp*_b  clean4w*_b clean7d*_b clean1d*_b  cook4w*_b  cook7d*_b cook1d*_b scavenge*_b beg*_b farm*_b  brush4w*_b brush7d*_b brush1d*_b  drugsell4w*_b  drugsell7d*_b drugsell1d*_b drugsellever*_b drugselllast_b drugselllastunit_b workoth1*_b workoth2*_b  ownbiz*_b   , after ( ECO_ACT_b)
		placevar startbizever_b startbizeverspecify_b startbizexp_b startbizexpunit_b startbizlast_b startbizlastunit_b , after ( ownbizlastunit_b)

	* Financial
		placevar savefreq_b savewself_b savewperson_b savesusu_b savesusutype_b saveclub_b savebank_b savingsamt_b savingsamtunit_b debts_b debtamt_b debtamtunit_b debtpayback_b loan50who_b loan50whoother_b loan300who_b loan300whoother_b loanldwho_b loanldwhoother_b loan100pay110_b loan100pay110for_b, after ( loanldsources_b)
		placevar savefor_b saveforoth_b, after ( saveothforoth_b)
		placevar debtoth_b debtothamtunit_b , after( debtbnkmicrofunit_b)

	* Voting
		placevar vote2005prezr1_b- voassociationmeetings_b, after ( voteprezpref_b)

	* War
		placevar  textwar2_b, after ( WAR_b)

	* Family and Peer
// 		placevar peerschool1_b peerschool2_b peerschool3_b peerschool4_b peerschool5_b, after ( FAMILY_PEER_b)
		placevar famquarrel_b, after (famhelp_b)
		placevar peeradvice_b, after (peerguard_b)
		placevar peerpalava_b, after (peershare_b)


	* Gender
		placevar mrelations_b mrelationscondoms_b mgift_b mmoney_b maccuse_b mthreat_b minsult_b mhit_b mownopinionok_b mrefusesexok_b mwithholdfundsok_b mbeatok_b, before ( HOUSEHOLD_b)

	* Community
		placevar gdrama_b gsport_b gsusu_b gyouth_b gschool_b gtown_b grel_b gcoop_b gbus_b goth_b gothspecify_b groupnum_b   groupstart_b glead_b leader_b  groupcommleader_b bigman_b disobey_b serious_b serious2_b lendhand_b cando_b troubleneighbors_b commmeet_b  causeconfusion_b   commchange6mx_b commchangewhy_b commchangewhyspecify_b ordinaryattacked_b safecomm_b carryweapon_b carryweaponhowoften_b carryweapondaynight_b carryweaponkind_b carryweaponkindoth_b carrytradprotect_b carrytradprotectkind_b carrytradprotectother_b quarrelsome_b palsamepot_b pallead_b palneigh_b fights_b weapons_b fightsmllead4w_b fightbiglead4w_b fightsmlneigh4w_b fightbigneigh4w_b fightphys4w_b fightweapon4w_b fine4w_b policestation4w_b , after ( COMMUNITY_b)
		placevar fightsmlleader4w_b, after(fightsmllead4w_b)
		placevar fightbigleader4w_b, after ( fightbiglead4w_b)
		placevar fightsmlpolice4w_b, after( fightphys4w_b)
		placevar fightsmlpolice4w_b  fightbigpolice4w_b , after(  policestation4w_b)

	* Time and Risk
		placevar perception_drinking_b perception_drugs_b time_decl_*_b time_hyp_*_b time_wait*_b   risk_decl_*_b , after ( TIME_RISK_b)

	* Drugs
		placevar drinkbooze*_b addbooze*_b drinkbeerwine*_b drinkgin*_b druggrass*_b druggrass*_b adddruggrass*_b drugntgrss*_b drugntgrss*_b adddrugntgrss*_b drugsever*_b drugsellfriends_b drugsellfriendsspecify_b drugsellself_b drugsellselfspecify_b drugsellselfspecifyoth_b, after (   DRUGS_b)
		placevar drugsell2wx_b, after (drugsellself_b)


	* Health
		placevar alive10yr_b alive5yr_b alive1yr_b alive1mo_b alive1wk_b slphungry4wx_b, after ( aliveage100_b)
		placevar  slphungry2wdys_b slphungry4wx_b, after ( slphungry7dx_b)

	* Psychoso
		placevar  baddestroy_b  , after ( takethings_b)

	* Housing
		placevar sleepstreet12m_b sleepstreet12mamt_b sleepstreet12mamtunit_b sleeptheft_b victimhouserob6m_b victimhouserob6mamt_b victimhouserob6mamtunit_b threatlife6m_b threatlife6mx_b physattack6m_b physattack6mx_b, after ( fearpeople_b)

	* Consumption
		placevar goodfood1d_b smallfood1d_b meat1d_b goodfood2d_b smallfood2d_b meat2d_b smallfood7d_b smallfood7dunit_b  drinkwater3dx_b drinkwater7d_b drinkwater7dunit_b drinkjuice3dx_b drinksoft3dx_b drinksoft7d_b drinksoft7dunit_b drinkgin3dx_b   drinkgin3dunit_b drinkalcohol7d_b drinkalcohol7dunit_b drinkplmwine3dx_b drinkplmwine3dunit_b drinkhot3dx_b drinkbeer3dx_b drinkmalta3dx_b  prostitution7dx_b prostitution7dxcost_b videoclub7dx_b cigarette7dx_b gamble7ddys_b gamble7damt_b gamble7damtunit_b gambleever_b gamble4wx_b med7d_b med7dunit_b transport7d_b  transport7dunit_b coal7d_b coal7dunit_b cookoil7d_b cookoil7dunit_b cellcredit7damt_b cellcredit7damtunit_b phonecharge7d_b phonecharge7dunit_b payphone7d_b payphone7dunit_b videoclub7d_b videoclub7dunit_b cigarette7d_b cigarette7dunit_b marijuana7d_b marijuana7dunit_b drugs7d_b drugs7dunit_b prostitution7d_b prostitution7dunit_b tempt1a_b tempt1b_b tempt2a_b tempt2b_b tempt3a_b tempt3b_b, after ( CONSUMPTION_b)

	* Household
		placevar  hhlivealone_b hhadvise_b hhconcerned_b hhhelpjammed_b hhpalavas_b hhshare_b hhsharefood_b, after (dependelderly_b)

	* IBM
// 		placevar gage_b gdate_b genumerator_b genumeratorspecify_b   gcontact_b gstarttime_b g1a_b cclcomplet_b paya_b payb_b payc_b payd_b, after ( GAMES_INTRO_b)
		placevar gage_b gdate_b   gcontact_b gstarttime_b g1a_b cclcomplet_b paya_b payb_b payc_b payd_b, after ( GAMES_INTRO_b)
		placevar g2c_b, after ( g2cms_b)
		placevar g3m1a_b g3m1e_b, after (GAMES_MAZE_b)
		placevar g3m2a_b g3m2e_b, after (g3m1ems_b)
		placevar g3m3a_b g3m3e_b, after ( g3m2ems_b)
		placevar g4b_b, after (g4a_b)
		placevar g4d_b, after (g4c_b)
		placevar g4f_b, after ( g4e_b)
		placevar g5g1e_b, after (g5g1d_b)
		placevar g5g2e_b, after (g5g2d_b)
		placevar g5g3e_b, after (g5g3d_b)
		placevar g5g4e_b, after (g5g4d_b)
		placevar g5g5e_b, after ( g5g5d_b)
		placevar digtestpractice_b digtest2_1v1_b digtest3_1v1_b digtest3_2v1_b digtest4_1v1_b digtest4_2v1_b digtest5_1v1_b digtest5_2v1_b digtest6_1v1_b digtest6_2v1_b digtest7_1v1_b digtest8_1v1_b, after (GAMES_MEMORY_b)
		placevar digopptestpractice_b digopptest2_1v1_b digopptest3_1v1_b digopptest3_2v1_b digopptest4_1v1_b digopptest4_2v1_b digopptest5_1v1_b digopptest5_2v1_b digopptest6_1v1_b digopptest6_2v1_b, after (digtest9_2v2_b)

	* Hustle
		placevar hupeer*_b  stealhustle_b   stealtempted_b  steal_b steal7d_b stealtakethings*_b  stealmistakecorr*_b  stealscrape*_b  stealpickpocket*_b  stealscam*_b  stealblackdeed*_b  stealmugger*_b  stealarmedrob*_b  stealweapon*_b  steallast*_b  stealhowoften_b  stealhow_b stealhowoth_b stealplancontinue_b stealsurvive_b, after (   HUSTLE_b)

	* Assets
		placevar  landtownld_b,after ( landtownunit_b)
		placevar motorcycles_b, after ( bicycles_b)
		placevar farmland_b, after ( landtownld_b)
		placevar  tables_b, after ( chairs_b)


	* Political violence
		placevar POLVIOL_b- pvhyppalpaid200ldwcheat_b, after ( se_notproud_b)


// ENDLINE

	* Consent
		placevar CONSENT_e mentcap_e   mentcap3_e hearconsent_e hearconsent2_e, after (datestart_e)

	* Intro
		placevar stylidnumber_e stylidcheck_e suspicious_e suspiciousspecify_e, after (warname_e)
// 		placevar  fakename_e fakenamespecify_e stylidname_e, after (warname_e)

	* Housing
		placevar victimhouserob3m_e victimhouserob3mamt_e victimhouserob3mamtunit_e victimtheft3m_e victimtheft3mamt_e victimtheft3mamtunit_e threatlife3m_e threatlife3mx_e physattack3m_e physattack3mx_e , after ( fearpeople_e)
		placevar sleepstreet4w_e- physattack4wx_e, after ( physattack3mx_e)
		placevar sleeptheft_e, after (sleepsafe_e)

	* Subjective Well Being
		placevar  happiness_e satisfaction_e health_e, after (SUBJ_WB_e)

	* Sexual Abuse
		placevar  sex1stage_e saadult_e sapeer_e, after(SEX_ABUSE_e)

	* Timing War Exp
		placevar  twbullets_e- twfighterlengthunit_e, after(TIMING_WAREXP)

	* Delay of Gratification
		placevar DELAY_GRATIFICATION_e drinktoday_e drinktodaytime_e eattoday_e eattodaytime_e sdflavor_e sdthirsty_e sdbottle_e sdtaste_e sdchoose_e sdchoosecheck_e sdchoosechecktime_e  sdchoosenow_e sdchooselater_e dg_hungry_e dg_candychoice_e dg_starttime_e dg_candies1_e dg_time1_e dg_candies2_e dg_time2_e dg_candies3_e dg_payout_e, after (hearconsent2_e)

	* IDVerification
		placevar  idv_tribe_e- idv_selfdrinkgin_e , after ( idv_lottogrntletter_e)
		placevar idv_rel_e idv_relchrist_e idv_mmalechild_e idv_mgemchild_e idv_peerexcom_e, after( idv_selfdrinkgin_e)

	* Demo
		placevar relmeet_e relmeetunit_e, after (DEMO_e)
		placevar lvg1*_e  lvg2*_e, after (DEMO_e)

	* Eco Activity
		foreach x in  workoth2 workoth1 drugsell    farm  beg scavenge  houseclswp  guard   carryload   moto  carwash carload  office  trade {
			placevar `x'2w_e `x'2w2_e `x'4w_e `x'4w2_e  `x'2wowner_e  `x'7ddys_e `x'7dhrs_e `x'7dcash_e `x'7dcashunit_e `x'7dprof_e `x'7dprofunit_e `x'prev7ddys_e `x'prev7dhrs_e `x'prev7dcash_e `x'prev7dcashunit_e `x'prev7dprof_e `x'prev7dprofunit_e `x'4wdys_e `x'4whrs_e `x'4wcash_e `x'4wcashunit_e `x'mercvaltxt_e `x'mercsval_e `x'mercsvalunit_e `x'equipval_e `x'equipvalunit_e `x'rawmatval_e `x'rawmatvalunit_e `x'structval_e `x'structvalunit_e `x'2winventoryamt_e `x'2winventoryamtunit_e `x'2wequipmentamt_e `x'2wequipmentamtunit_e `x'2wmaterialsamt_e `x'2wmaterialsamtunit_e `x'2wbizstructamt_e `x'2wbizstructamtunit_e, after (  ECO_ACT_e)
		}

		foreach x in pettytrade buysell table shop {
			placevar `x'2w_e `x'2w2_e `x'4w_e `x'4w2_e  `x'2wowner_e  `x'7ddys_e `x'7dhrs_e `x'7dcash_e `x'7dcashunit_e `x'7dprof_e `x'7dprofunit_e `x'prev7ddys_e `x'prev7dhrs_e `x'prev7dcash_e `x'prev7dcashunit_e `x'prev7dprof_e `x'prev7dprofunit_e `x'4wowner_e `x'4wspecify_e `x'4wdys_e `x'4whrs_e `x'4wcash_e `x'4wcashunit_e `x'mercvaltxt_e `x'mercsval_e `x'mercsvalunit_e `x'equipval_e `x'equipvalunit_e `x'rawmatval_e `x'rawmatvalunit_e `x'structval_e `x'structvalunit_e `x'2winventoryamt_e `x'2winventoryamtunit_e `x'2wequipmentamt_e `x'2wequipmentamtunit_e `x'2wmaterialsamt_e `x'2wmaterialsamtunit_e `x'2wbizstructamt_e `x'2wbizstructamtunit_e, after (  ECO_ACT_e)
		}

		placevar trade2wspecify_e, after (trade4w2_e)
		placevar trade4wspecify_e trade4wspecifyoth_e,  after (trade4w_e)
		placevar office4wspecify_e, after (office4w_e)
		placevar office2wspecify_e, after (office4w2_e)
		placevar workoth12wspecify_e workoth14wspecify_e, after (  workoth12w2_e)
		placevar workoth22wspecify_e workoth24wspecify_e, after (  workoth22w2_e)
		placevar cash4w_e- save4wunit_e, after ( saveprev7dunit_e)

	* Financial
		placevar  loan100pay110_e loan100pay110for_e cashgiftrecd*_e schlfeechild*_e schlfeepartner*_e schlfeeothers*_e childsprt*_e	partnersprt*_e  partnergifts*_e cashgiftgiven*_e grantrecdfromlucky2*_e grantgavetounlucky2*  savefreq_e savesusu*_e saveclub*_e savebank*_e savewperson*_e   savewself*_e saveoth*_e saveuse*_e debt*_e, after (FINANCIAL_e)
		placevar  savefor_e saveforoth_e, after( saveusewhy_e)

	* Drugs and Alcohol
		placevar drinkbooze*_e addbooze*_e   druggrass*_e adddruggrass*_e drugntgrss*_e drugntgrss*_e adddrugntgrss*_e  drugtablet*_e drughard*_e  drugsellself_e drugsell2wx_e drugsellselfspecify_e drugsellselfspecifyoth_e, after ( DRUG_e)

	* Health
		placevar  slphungry7dx_e, after (slphungry2wdys_e)

	* Family
		placevar  fexcoms_e- talkcommunit_e, after( famhelp_e)

	* Community
		placevar  groupnum_e groupcommleader_e leader_e bigman_e groupstart_e serious_e cando_e commmeet_e commmeet4wx_e  commchange6mx_e ///
		commchangewhy_e commchangewhyspecify_e commchangeplan_e commintendtostay_e commoneyear_e  volroad6mx_e volwater6mx_e volbldgoth6mx_e volschl6mx_e vollatrine6mx_e voloth6mx_e ///
		volfuneral6mx_e volcommittee_e  carryweapon_e carryweaponhowoften_e carryweapondaynight_e carryweaponkind_e carryweaponkindoth_e   fightsmllead*_e  fightbiglead*_e ///
	    fightsmlpolice*_e  fightbigpolice*_e fightsmlneigh*_e  fightbigneigh*_e fightphys*_e  fightweapon*_e  fine*_e  policestation*_e  policejail*_e, after ( COMMUNITY_e)

	* Hustle
		placevar  hupeerwhat_e hupeerpickpocket_e hupeerscam_e hupeermugger_e hupeerarmedrob_e stealtakethings*_e stealmistakecorr*_e stealscrape*_e stealpickpocket*_e stealscam*_e stealblackdeed*_e stealmugger*_e stealarmedrob*_e  stealweapon*_e  stealsurvive*_e steallast*_e, after (HUSTLE_e)

	* Consumption
		placevar foodckshp*_e  foodhvyoth*_e  foodbiscuits3d_e foodcandy3d_e foodpeanuts3d_e foodchips3d_e fooddonuts3d_e foodkala3d_e foodpolo3d_e foodplantain3d_e  ///
		foodegg3d_e foodcassava3d_e foodpotato3d_e foodeddoes3d_e foodfish3d_e foodchicken3d_e foodmeat3d_e foodswtmeat3d_e foodpigtail3d_e drinkwater3dx_e drinkjuice3dx*_e   ///
		drinksoft3dx*_e drinkgin*_e  drinkplmwine3d*_e    drinkhot3*_e drinkbeer3dx*_e   drinkmalta3d*_e clothes2w*_e  clothes4w*_e  shoes2w*_e  shoes4w*_e  jewelry*_e  cellcredit2w*_e  cellcredit7d*_e    ///
		phonecharge*_e  payphone*_e  transport*_e  bigtriplsttime*_e  cosmetics*_e  med*_e  prostitution*_e  videoclub*_e  cigarette*_e  gamble*_e  schlfeeself*_e  dur*_e ,  after ( CONSUMPTION_e)

	* Voting
		placevar voteplanreg_e voteregrecruited_e voteregrecruitedpd_e voteregrecruitedpdamt_e voteregrecruitedpdamtunit_e votereg_e voteregnowhy_e voteregnowhyoth_e, after ( vote2011knowcandidates_e)

	* Program Experiences
		placevar lottogrntanysmallhelp_e- lottogrntfair_e, after(PROG_EXP_e)
		placevar lottotpanysmallhelp_e lottotpanysmallhelpnum_e lottotpcrrptn_e lottotpcrrptnhow_e lottotpfair_e- lottotpinflhow_e, after (lottogrntfair_e)
		placevar offerredtplookup_e winlticketlookup_e lottotpdes_e lottotpplay_e- lottotpplaychecknowhy_e lottotpsuccess_e lottotpwin_e lottotphow_e- lottotppaperwinlose_e lottotpnocmpsn_e lottotpnocmpsnspecify_e lottotpselect_e, after (lottotpinflhow_e)
		placevar lottotpselectwithoutwin_e lottotpselectwithoutwinhow_e lottotpselectswitch_e lottotpselectswitchhow_e lottotpselectcmpsn_e lottotpselectnoplaycmpsn_e lottotpselectdrawagain_e lottotpselectdrawagainhow_e lottotpnoselectdrawagain_e lottotpnoselectdrawagainhow_e lottotpselectseesmall_e lottotpselectseesmallhow_e lottotpnoselectseesmall_e lottotpnoselectseesmallhow_e, after (lottotpselect_e)
		placevar lottotpselectothhelp_e lottotpselectothhelphow_e lottotpnoselectothhelp_e lottotpnoselectothhelphow_e lottotpselectexpl_e lottotpnoselectwithwin_e lottotpnoselectwithwinhow_e lottotpnoselectpreventwin_e lottotpnoselectpreventwinhow_e lottotpselectinfl_e lottotpselectinflhow_e, after ( lottotpnoselectseesmallhow_e)
		placevar tpcheck_e- tprecommend_e lottotpselectletter_e- lottotpnoselectletterkeep_e peidwhere_e peiddestroywhy_e, after ( lottotpselectinflhow_e)
		placevar tpcounselsite_e- tpcounseltrust_e, after (peiddestroywhy_e)
		placevar grantunspent_e- grantotherspecify_e, after (tpcounseltrust_e)
		placevar granttell_e- grantpaidrentamtunit_e, after (grantotherspecify_e)

	* Move Business Exp - Gender before ccl
		placevar  BUSINESS_EXP_e - gpayout_e, before (CCL_e)

	* Bix Exp
		placevar bizstructamt_e- bizotherspecify_e, after ( bizstorageamtunit_e)

	* Time and Risk
		 placevar perception_drinking_e perception_drugs_e, after ( TIME_RISK_e)
		 placevar time_hyp_mnygm1v2_e- risk_hyp_mnygm10v2_e, after ( risk_hyp_mnygm10_e)
		 placevar  time_decl_troublestarting_e- risk_decl_guineabuygoods_e, after ( risk_hyp_mnygm10v2_e)

	* Family
		placevar  PEER_e- famhelp_e fexcoms_e- talkcommunit_e,  before ( HOUSEHOLD_e)


	* IBM
		placevar g9a_e g9b_e g9c_e g9d_e g9e_e g9f_e g9g_e g9h_e g9i_e g9j_e gpayout_e, after (GAMES_MONEY_e)
		placevar g9ev2_e g9fv2_e g9gv2_e g9hv2_e g9iv2_e g9jv2_e, after (g9j_e)
		placevar g10a_e g10b_e g10c_e g10d_e g10e_e g10f_e, after (g9jv2_e)
		placevar g11*_e, after (g10f_e)
		placevar GAMES_MEMORY_e digtest*_e digopptest*_e  , before (GAMES_MONEY_e)
		placevar GAMES_LITERACY_e g6*e, before (GAMES_MEMORY_e)
		placevar GAMES_ARROW_e g4*_e, before (GAMES_LITERACY_e)
		placevar GAMES_MAZE_e g3*_e, before (GAMES_ARROW_e)
		placevar GAMES_PUZZLE_e g2*_e, before (GAMES_MAZE_e)
// 		placevar GAMES_INTRO_e genumerator_e genumeratorspecify_e gcontact_e gdataclerk_e gstarttime_e ibmdate_e gendtime_e g1a_e gpayout_e, before (GAMES_PUZZLE_e)
		placevar GAMES_INTRO_e gcontact_e gstarttime_e ibmdate_e gendtime_e g1a_e gpayout_e, before (GAMES_PUZZLE_e)
// 		placevar gdataclerkspecify_e, after ( gdataclerk_e)
		placevar digtest2_1v1_e digtest3_1v1_e digtest3_2v1_e digtest4_1v1_e digtest4_2v1_e digtest5_1v1_e digtest5_2v1_e digtest6_1v1_e digtest6_2v1_e digtest7_1v1_e digtest8_1v1_e, after (GAMES_MEMORY_e)
		placevar digopptest2_1v1_e digopptest3_1v1_e digopptest3_2v1_e digopptest4_1v1_e digopptest4_2v1_e digopptest5_1v1_e digopptest5_2v1_e digopptest6_1v1_e digopptest6_2v1_e, after (digtest9_2v2_e)
		placevar g9e_e g9f_e g9g_e g9h_e g9i_e g9j_e, after (g9d_e)
		placevar gpayout_e, after (g11v1specify_e)
		placevar gendtime_e, after (gstarttime_e)
		placevar beginlit_e- g12v1_e, after ( g11v1specify_e)

	* Household
// 		placevar hhcanwork_e hhtoosick_e dependu15_e dependelderly_e, after ( hhheadname_e)

	* Move IDV, COLLVIOL, POLVIOL, NORMSCRIM, NORMSVIOL, and WELLBEING before conclusion

		placevar IDV_e- cvhypvjgroup_e, before ( CCL_e)
		*placevar  ELECTIONS_e- crrighyouth_e, after ( cvhypvjgroup_e)

	 placevar SUBJ_WB_e- twfighterlengthunit_e, after ( CCL_e)

// DROP VARIABLES
	drop timestamp_* stime_*
	drop _merge_*
	drop softstart_b
	drop text_warfighter_e
	drop text_wardisplaced_e
	drop text_warbattles_e text_warrefugee_e
	drop text_warbulletsfam_e
	drop endtw_e rsmtw_e startdrugs_e endda_e rsmda_e starthustle_e texthustle1_e texthustle2_e texthustle3_e texthustle4_e texthustle5_e endhu_e rsmhu_e startcv_e
	drop endcv_e rsmcv_e startcs_e textcsmpt1_e textcsmpt2_e textcsmpt3_e textcsmpt4_e textcsmpt5_e textcsmpt52_e endcs_e rsmcs_e startfam_e textfam1_e textfam3_e textfam5_e textfam6_e endfam_e rsmfam_e startcomm_e textcy1_e endcy_e rsmcy_e startcc_e textconcl1_e textconcl2_e
	drop textintro1_e textintro3_e textintro4_e textintro2_e endin_e rsmin_e startcn_e mentcap2_e mentcap4_e textconsent1_e textconsent2_e textconsent3_e textconsent6_e textconsent7_e textconsent8_e textconsent9_e textconsent18_e textconsent19_e textconsent20_e textconsent21_e textconsent22_e textconsent23_e textconsent24_e textconsent25_e textconsent26_e endcn_e textidv1_e rsmcn_e textidv2_e enddg_e rsmdg_e startde_e textdemo2_e textdemo3_e endde_e rsmde_e swstart_e textsw_e text_happiness_e text_satisfaction_e text_health_e endsw_e rsmsw_e starths_e texthl1_e endhs_e rsmhs_e starthg_e texthg1_e endhg_e rsmhg_e startnc_e textnc1_e textnc2_e endnorm_e rsmnorm_e startnv_e textnv1_e endnv_e rsmnv_e sastart_e textsa1_e  textsa2_e  endsa_e rsmsa_e starttr_e texttr1_e texttr2_e text_time_decl_medicine_e text_risk_decl_surgerychoice_e text_time_wait1wfor3mcntrct1_e text_time_wait1wfor3mcntrct2_e text_time_wait1wfor3mcntrct3_e text_risk_decl_guineabuygoods1_e text_risk_decl_guineabuygoods2_e texttr3_e texttr4_e texttr5_e endtr_e rsmtr_e startecon1_e startecon1_e textecon11_e textecon12_e textecon13_e textecon14_e endecon1_e startecon2_e textecon2_e endecon2_e rsmecon2_e startfi_e textfi1_e textfi3_e endfi_e rsmfi_e twstart_e twconsent_e texttw1_e texttw2_e texttw3_e text_warbullets_e
	drop resume_e
	drop merge*
	drop dum*
// 	drop lastname_e firstname_e nickname_e
	drop recordid_e unitid_e
// 	drop username_*
	drop endsurvey_e

// SAVE DATASET


	save "./clean/STYL_lr_panel.dta", replace
	cd $direc
